//
//  DHDoctorCollectionViewCell.m
//  DHKuaiYi
//
//  Created by 韩旭 on 16/11/13.
//  Copyright © 2016年 30-陈辉华. All rights reserved.
//

#import "DHDoctorCollectionViewCell.h"
#import "Masonry.h"
@implementation DHDoctorCollectionViewCell

- (void)awakeFromNib {
    
   [super awakeFromNib];
    [self setupUI];
    
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
    
}

/**
 初始化
 */
- (void)setupUI {
    
    self.backgroundColor = [UIColor whiteColor];
    //图片控件
    UIImageView *imageView = [[UIImageView alloc]init];
    self.imageView =imageView;
    self.imageView.image= [UIImage imageNamed:@"1.jpg"];
    [self addSubview:imageView];
    
    //label
    UILabel *label=[[UILabel alloc]init];
    self.label = label;
    self.label.text =@"肿瘤";
    self.label.textColor = [UIColor XHH_colorWithHex:0x5e5e5e];
    [self addSubview:label];

    /*---------- 自动布局 ----------*/
    /*---------- 适配高度的计算 ----------*/
    CGFloat sOne = (float)50 / 94.5;
    CGFloat sTwo = (float)12 / 94.5;
    CGFloat sThree = (float)15 / 94.5;
    
    //margin
    CGFloat sOneMargin = sOne * self.frame.size.height;
    CGFloat sTwoMargin = sTwo * self.frame.size.height;
    CGFloat sThreeMargin = sThree * self.frame.size.height;
    
    self.label.font = [UIFont systemFontOfSize:sTwoMargin];
    CGSize imgSize = CGSizeMake(sOneMargin, sOneMargin);
    
    //自动布局
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView).offset(sThreeMargin);
        make.centerX.mas_equalTo(self.contentView);
        make.size.mas_equalTo(imgSize);
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.imageView).offset(sThreeMargin * 4);
        make.centerX.mas_equalTo(self.imageView);
    }];
}
@end













